<html>

<head>
<title>Singleton Pattern</title>
<link rel="stylesheet" type="text/css" href="../../../style.css">
</head>

<body>

<h1>Singleton </h1>
<ul>
  <li><a href="#Purpose">Purpose</a></li>
  <li><a href="#Structure">Structure</a></li>
  <li><a href="#Applications">Applications</a></li>
  <li><a href="#Consequences">Consequences</a></li>
</ul>
<h2><a name="Purpose">Purpose</a></h2>
<ul type="square">
  <li>Ensure a class only has one instance, and provide a global point of access 
	to it.</li>
</ul>
<h2><a name="Structure">Structure</a></h2>
<p>&nbsp; <img border="0" src="Singleton_Model1.gif" width="350" height="147"></p>
<ul type="square">
  <li><font face="Verdana"><b>Singleton: </b>defines an Instance operation that 
	lets clients access its unique instance. Instance is a class operation (that 
	is, a class method in Smalltalk and a static member function in C++).<br>
	may be responsible for creating its own unique instance.</font></li>
</ul>
<h2><a name="Applications">Applications</a></h2>
<ul type="square">
  <li>there must be exactly one instance of a class, and it must be accessible 
	to clients from a wellknown access point.</li>
  <li>when the sole instance should be extensible by subclassing, and clients 
	should be able to use an extended instance without modifying their code.</li>
</ul>
<h2><a name="Consequences">Consequences</a></h2>
<ul type="square">
  <li><b>Controlled access to sole instance. </b>Because the Singleton class 
	encapsulates its sole instance, it can have strict control over how and when 
	clients access it.</li>
  <li><b>Reduced name space. </b>The Singleton pattern is an improvement over 
	global variables. It avoids polluting the name space with global variables 
	that store sole instances.</li>
  <li><b>Permits refinement of operations and representation. </b> The Singleton 
	class may be subclassed, and it's easy to configure an application with an 
	instance of this extended class. You can configure the application with an 
	instance of the class you need at run-time.</li>
  <li><b>Permits a variable number of instances. </b>The pattern makes it easy 
	to change your mind and allow more than one instance of the Singleton class. 
	Moreover, you can use the same approach to control the number of instances 
	that the application uses. Only the operation that grants access to the 
	Singleton instance needs to change.</li>
</ul>

</body>

</html>
